package com.algorithm.entitys;/*
 *@Author:DOWN
 *@Date:2021/12/11 11:04
 *@Comment:
 */

public class Student implements Comparable<Student> {
    private String name;
    private int score;

    public Student(String name) {
        this.name = name;
    }

    public Student(int score) {
        this.score = score;
    }

    public int getScore() {
        return score;
    }

    public void setScore(int score) {
        this.score = score;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    //类默认比较的是地址
    @Override
    public boolean equals(Object item) {
        //本身比较true-同一个内存地址      1
        if (this == item) {
            return true;
        }
        //空判断                        2
        if (item == null) {
            return false;
        }
        //类型判断                      3
        if (item.getClass() != this.getClass()) {
            return false;
        }
        Student newItem = (Student) item;
        return this.name.equals(newItem.name);
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", score=" + score +
                '}';
    }

    @Override
    public int compareTo(Student item) {
        return this.score - item.score;
    }
}
